import fetch from '@system.fetch'

export default function() {
  return new Promise(resolve => {
    fetch
      .fetch({
        url: `https://cdn.1rtb.com/js/app.json?${new Date().getFullYear()}${new Date().getMonth()}${new Date().getDate()}`
      })
      .then(response => {
        try {
          const { app } = JSON.parse(response.data.data)
          resolve(app)
        } catch (e) {
          throw new Error(e)
        }
      })
      .catch(e => {
        resolve([])
        console.error(e)
      })
  })
}
